package com.opoc.utils;

import lombok.Data;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: opoc
 * @description:
 * @author: lyx
 * @create: 2023-10-25 19:35
 */
public class TimeUtils {
    public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd/");
    /**
     * 获取时间*/
    public static Date getTime(){
        Date date = new Date();
        return date;
    }
    public static Timestamp getTimeStamp(){
        return new Timestamp(System.currentTimeMillis());
    }
    public static java.sql.Timestamp StringDateToSqlDate(String time) throws ParseException {
        if (time == null){
            return null;
        }
        return new java.sql.Timestamp(DATE_TIME_FORMAT.parse(time).getTime());
    }

    public static String SqlDateToStringDate(java.sql.Timestamp time){
        if (time == null){
            return null;
        }
        java.util.Date date= new Date(time.getTime());
        return DATE_TIME_FORMAT.format(date);
    }
}
